package com.hcl.orm.core.dialect.handler.page;

import com.hcl.orm.core.dialect.SqlDefinition;
import com.hcl.orm.core.dialect.Signature;
import com.hcl.orm.core.dialect.handler.AbstractDialectHandler;

/**
 * @author hucl
 * @projectName hcl-orm
 * @description: TODO
 * @date 2021/8/1318:09
 */
public abstract class QueryPageDialectHandler extends AbstractDialectHandler {
    /**
     * SQL Select字段提取正则
     */
    protected static final String FIELDS_PATTERN = "(?i)(?<=select).*(?=from)";
    /**
     * 统计行数SQL模板
     */
    protected static final String SIMPLE_PAGE_QUERY_COUT_TMPL = "select count(*) from {}";
    public QueryPageDialectHandler(String name) {
        super(name);
    }


    @Override
    protected boolean needHandled(SqlDefinition sqlDefinition) {
        return sqlDefinition.getSignature().isReturnsPage();
    }
}
